package com.ruoyi.core.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.core.service.CustomTimeService;
import com.ruoyi.core.vo.CustomTimerDTO;
import com.ruoyi.core.vo.ProductFunctionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;

/**
 * @Author xiaom
 * @Date 2020/12/22 13:46
 * @Version 1.0.0
 * @Description <>
 **/
@RestController
@Validated
@Api(tags = "自定义功能管理")
@RequestMapping("/custom-time")
public class CustomTimeController extends BaseController {

    @Autowired
    private CustomTimeService customTimeService;

    @PostMapping("/getProductFunctionUseCount")
    @ApiOperation("获取产品内功能已经使用的次数")
    public AjaxResult getProductFunctionUseCount(@RequestBody ProductFunctionVo productFunctionVo){
        return AjaxResult.success(customTimeService.getFunctionUseCount(productFunctionVo.getProductId(), productFunctionVo.getType()));
    }

    @PostMapping("/addProductFunctionUseCount")
    @ApiOperation("增加产品内部功能在当月的使用次数")
    public AjaxResult addProductFunctionUseCount(@RequestBody ProductFunctionVo productFunctionVo){
        return AjaxResult.success(customTimeService.addFunctionUseCount(productFunctionVo.getProductId(), productFunctionVo.getType()));
    }
}
